<?php include_once('header.php');?>
	<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<ul class="breadcrumb">
				<li>
					<i class="icon-home home-icon"></i>
					保险公司管理
				</li>
				<li>
					保险公司列表
				</li>
			</ul>
		</div>
		<div class="page-content">
			<div class="page-header">
				<h1 class="blue"><i class="icon-edit"></i> 编辑保险公司信息</h1>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<form class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="/www/insure/edit"  onsubmit="return check()">
						<input type="hidden" id="id" name="id" value="<?php echo $data['id'];?>" />
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">保险公司名称:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="company_name" name="company_name" value="<?php echo $data['company_name'];?>">
							</div>
						</div><div class="form-group">
							<label for="title" class="col-sm-1 control-label">联系电话:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" id="phone" name="phone" value="<?php echo $data['phone'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">备注:</label>
							<div class="col-sm-6">
								<textarea class="form-control" rows="4" name="remark"><?php echo $data['remark'];?></textarea>
							</div>
						</div>
					 	<div class="form-group">
					   		<div class="col-sm-offset-1 col-sm-10">
								<button type="submit" id="submit" class="btn btn-primary">确定</button>
								<button type="submit" id="cancel" class="btn btn-primary">取消</button>
							</div>
					  	</div>
					</form>	
				</div>
			</div>					
		</div>													
	</div>
<?php include_once('content.php');?>
	<link href="/public_source/www/assets/css/ace.min.css" rel="stylesheet" />	
	<link href="/public_source/www/assets/css/jquery.tag-editor.css" rel="stylesheet"/>
    <script src="/public_source/www/assets/js/bootbox.min.js"></script>  
	<script src="/public_source/www/assets/js/jquery.tag-editor.min.js"></script>
	<script src="/public_source/www/js/areas.js"></script>
<?php include_once('footer.php');?>	
<script type="text/javascript">
	$(document).ready(function(){
		$("#cancel").click(function() {
			window.location.replace('/www/insure/insure_list');
			return false;
		});
	});
	function check() {
	   var company_name = document.getElementById("company_name").value;
	   var phone = document.getElementById("phone").value;
	   var phoneReg=/^0?1[3584][0-9][0-9]{8}$/;
	   var id = document.getElementById("id").value;
	   var data = {company_name:company_name,id:id};
	   var bool = true;
	   if(company_name ==  null || company_name == '') {
	        alert("保险公司名不能为空");
	        return false;
	   }
	   if(phone ==  null || phone == '') {
	        alert("手机号码不能为空");
	        return false;
	   }
	   if(!phoneReg.test(phone)){
	        alert("手机号码格式错误");
	        return false
	 	}
	   $.ajax({
			url:"/www/insure/check_sole",
			async: false,
			type:"post",
			data: data,
			dataType: 'json',
			success:function(data) {
				bool = data;
			}	
		});
		if(!bool) {
			 alert("保险公司名已存在");
			 return false;	
		}
	   return true;
	}			
</script>		